package com.yehuishou.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.yehuishou.pojo.ReceiverAddress;
import com.yehuishou.service.ReceiverAddressService;

/**
 * 
 * @author VULCAN
 *
 */
@Controller
public class ReceiverAddressController {
	
	@Autowired
	private ReceiverAddressService receiverAddressService;
	
	@RequestMapping("/content-10_1")
	public String selectAll(@RequestParam(required = true, defaultValue = "1") Integer pageNum,
			@RequestParam(required = true, defaultValue = "10") Integer pageSize,Model model,Integer sreceiverid) {
		PageHelper.startPage(pageNum, pageSize);
		List<ReceiverAddress> rd = receiverAddressService.findAll(sreceiverid);
		PageInfo<ReceiverAddress> p = new PageInfo<ReceiverAddress>(rd);
		model.addAttribute("rd",rd);  	  //数据
		model.addAttribute("page",p);	  //分页
		
		return "content-10_1";
	}
	
	
	@RequestMapping("/updateRd")
	public String toupdate(Integer sreceiverid,Model model) {
		ReceiverAddress rd =receiverAddressService.findById(sreceiverid);
		model.addAttribute("rd",rd);  	  //数据
		return "content-10_2";
	}
	
	
	@RequestMapping("/updateRdRd")
	public String updateRdRd(ReceiverAddress receiverAddress) {
		
		Integer integer = receiverAddressService.updateAddress(receiverAddress);
		
		return "redirect:content-10_1";
	}

}
